import { getThemeConfig } from '../utils/theme';
import { isIphoneX } from '../utils/index';

export default {
  hasLogin: state => state.app.hasLogin,
  token: state => state.app.token,
  userInfo: state => state.app.userInfo,
  baseInfo: state => state.app.baseInfo,
  settings: state => state.app.settings,
  // 是否是会员
  isMember: state => {
    const expired = state.app.baseInfo.member ? +state.app.baseInfo.member.expired : 0;
    return expired > Date.now();
  },
  userid: state => state.app.userInfo.userid,
  redirect: state => state.app.redirect,
  loading: state => state.loading,
  shareCode: state => state.app.userInfo.shareCode,
  bookDetailShare: state => state.bookdetail.showShare,
  autoSecretCode: state => state.bookdetail.autoSecretCode,
  themeConfig: state => {
    return getThemeConfig('READER_THEME', state.reader.theme)
  },
  isIphoneX: () => isIphoneX(),
};
